<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace longbingcore\wxcore;

class aliyunVirtual
{
    public static function createClient($uniacid)
    {
        $configmodel = new \app\massage\model\Config();
        $config = $configmodel->dataInfo(["uniacid" => $uniacid]);
        $accessKeyId = trim($config["short_id"]);
        $accessKeySecret = trim($config["short_secret"]);
        $config = new \Darabonba\OpenApi\Models\Config(["accessKeyId" => $accessKeyId, "accessKeySecret" => $accessKeySecret]);
        $config->endpoint = "dyplsapi.aliyuncs.com";
        return new \AlibabaCloud\SDK\Dyplsapi\V20170525\Dyplsapi($config);
    }
    public function bindPhone($uniacid, $phoneA, $phoneB, $expiration, $poolKey, $out_id, $isRecordingEnabled = true)
    {
        $client = self::createClient($uniacid);
        $bindAxbRequest = new \AlibabaCloud\SDK\Dyplsapi\V20170525\Models\BindAxbRequest(["phoneNoA" => $phoneA, "phoneNoB" => $phoneB, "expiration" => $expiration, "isRecordingEnabled" => $isRecordingEnabled, "poolKey" => $poolKey, "outId" => $out_id]);
        $runtime = new \AlibabaCloud\Tea\Utils\Utils\RuntimeOptions([]);
        try {
            $res = $client->bindAxbWithOptions($bindAxbRequest, $runtime);
            $res = object_array($res);
            return !empty($res["body"]) ? $res["body"] : [];
        } catch (\Exception $error) {
            if(!$error instanceof \AlibabaCloud\Tea\Exception\TeaError) {
                $error = new \AlibabaCloud\Tea\Exception\TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            return $error->message;
        }
    }
    public function delBind($uniacid, $subsId, $phoneX, $poolKey)
    {
        $client = self::createClient($uniacid);
        $unbindSubscriptionRequest = new \AlibabaCloud\SDK\Dyplsapi\V20170525\Models\UnbindSubscriptionRequest(["subsId" => $subsId, "secretNo" => $phoneX, "productType" => "AXB_170", "poolKey" => $poolKey]);
        $runtime = new \AlibabaCloud\Tea\Utils\Utils\RuntimeOptions([]);
        try {
            $res = $client->unbindSubscriptionWithOptions($unbindSubscriptionRequest, $runtime);
            $res = object_array($res);
            return !empty($res["body"]) ? $res["body"] : [];
        } catch (\Exception $error) {
            if(!$error instanceof \AlibabaCloud\Tea\Exception\TeaError) {
                $error = new \AlibabaCloud\Tea\Exception\TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            \AlibabaCloud\Tea\Utils\Utils::assertAsString($error->message);
        }
    }
}

?>